package voldTransfo;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import org.eclipse.emf.common.util.EList;
import org.eclipse.uml2.uml.Package;

import uml2Java.UMLChargeur;

public class TestUMLChargeur {
	private UMLChargeur _chargeur;
	private String _path;
	
	@Before
	public void setUp() throws Exception {
		_path = "modele_de_test/test.uml";
	
		_chargeur = new UMLChargeur(_path);
	}

	@Test
	public void testLoadResource() {
		assertNotNull(_chargeur.loadResource());
	}
	
	@Test
	public void testLoadUMLModel() {
		assertTrue(_chargeur.loadUMLPackage() instanceof Package);
	}
	
	@Test
	public void testLoadPackageRacine() {
		assertEquals(_chargeur.loadUMLPackage().getName(), "package_racine");
	}
	
	@Test
	public void testLoadUMLSubPackages() {
		EList<Package> subpackages = _chargeur.loadUMLSubPackages();
		assertTrue(subpackages.size() == 2);
		assertEquals(subpackages.get(0).getName(), "test1"); 
		assertEquals(subpackages.get(1).getName(), "test2");
	}
	
	@After
	public void tearDown() throws Exception {
		_chargeur = null;
	}

}
